package com.woniu.common.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.handler.MessageContext;

@Configuration
public class RabbitConfiguration {
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Queue queueinsertorder() {
        return new Queue("queueinsertorder");
    }

    @Bean
    public TopicExchange exchangeinsertorder(){
        return new TopicExchange("exchangeinsertorder");
    }

    @Bean
    public Binding bindingqueueinsertordertoexchangeinsertorder(Queue queueinsertorder,TopicExchange exchangeinsertorder){
        return BindingBuilder.bind(queueinsertorder).to(exchangeinsertorder).with("#.insertorder.#");
    }


}
